Skip to content

Conversation

@hjyamauchi
Copy link
Contributor

@hjyamauchi hjyamauchi commented Nov 20, 2025

For #85606

This is to fix an overload ambiguity error that occur because the
C/C++ types double and long double are typealias to each other in
Swift on Windows and the system C++ header cmath.h defines a remquo
function overload for long double which conflicts with the one in the
C header corecrt_math.h in Swift.

@hjyamauchi
Copy link
Contributor Author

@swift-ci please test

@hjyamauchi hjyamauchi marked this pull request as ready for review November 20, 2025 19:27
@hjyamauchi hjyamauchi requested review from a team and artemcm as code owners November 20, 2025 19:27
For swiftlang#85606

This is to fix an overload ambiguity error that occur because the
C/C++ types double and long double are typealias to each other in
Swift on Windows and the system C++ header cmath.h defines a remquo
function overload for long double which conflicts with the one in the
C header corecrt_math.h in Swift.
@hjyamauchi
Copy link
Contributor Author

@swift-ci please test

@@ -295,7 +295,11 @@ public func lgamma(_ x: ${T}) -> (${T}, Int) {
@_transparent
public func remquo(_ x: ${T}, _ y: ${T}) -> (${T}, Int) {
var quo = Int32(0)
#if !os(Windows)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This problem should occur for any platform that doesn't differentiate long double from double right?

I think that rather than differentiating this on os(Windows), we want to use something to differentiate this based on sizeof(long double) == sizeof(double).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not exactly. This also requires another condition: the way the Windows headers declare it. This doesn't occur and the following reproducer test doesn't err on macos because the macos C++ header imports the C remquo into the std namespace for C++ rather than declaring another remquo for long double that would cause an overload with C remquo for long in Swift. I added text on it in the bug description here. So I think this is specific to Windows.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants